package com.ruoyi.app.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.app.domain.AppVoucherVerification;
import com.ruoyi.app.service.IAppVoucherVerificationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 验券记录Controller
 * 
 * @author dreamyy
 * @date 2025-11-26
 */
@RestController
@RequestMapping("/app/voucherVerification")
public class AppVoucherVerificationController extends BaseController
{
    @Autowired
    private IAppVoucherVerificationService appVoucherVerificationService;

    /**
     * 查询验券记录列表
     */
    @PreAuthorize("@ss.hasPermi('app:voucherVerification:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppVoucherVerification appVoucherVerification)
    {
        startPage();
        List<AppVoucherVerification> list = appVoucherVerificationService.selectAppVoucherVerificationList(appVoucherVerification);
        return getDataTable(list);
    }

    /**
     * 导出验券记录列表
     */
    @PreAuthorize("@ss.hasPermi('app:voucherVerification:export')")
    @Log(title = "验券记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppVoucherVerification appVoucherVerification)
    {
        List<AppVoucherVerification> list = appVoucherVerificationService.selectAppVoucherVerificationList(appVoucherVerification);
        ExcelUtil<AppVoucherVerification> util = new ExcelUtil<AppVoucherVerification>(AppVoucherVerification.class);
        util.exportExcel(response, list, "验券记录数据");
    }

    /**
     * 获取验券记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:voucherVerification:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appVoucherVerificationService.selectAppVoucherVerificationById(id));
    }

    /**
     * 新增验券记录
     */
    @PreAuthorize("@ss.hasPermi('app:voucherVerification:add')")
    @Log(title = "验券记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppVoucherVerification appVoucherVerification)
    {
        return toAjax(appVoucherVerificationService.insertAppVoucherVerification(appVoucherVerification));
    }

    /**
     * 修改验券记录
     */
    @PreAuthorize("@ss.hasPermi('app:voucherVerification:edit')")
    @Log(title = "验券记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppVoucherVerification appVoucherVerification)
    {
        return toAjax(appVoucherVerificationService.updateAppVoucherVerification(appVoucherVerification));
    }

    /**
     * 删除验券记录
     */
    @PreAuthorize("@ss.hasPermi('app:voucherVerification:remove')")
    @Log(title = "验券记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appVoucherVerificationService.deleteAppVoucherVerificationByIds(ids));
    }
}
